mssql

推荐列表 站点导航

当前位置:首页 > 数据库 > mssql >

动态SQL中返回数值的实现代码

来源:网络整理  作者:网络  发布时间:2020-12-08 16:19
最近在做一个paypal抓取数据的程序,由于所有字段和paypal之间存在对应映射的关系,所以所有的sql语句必须得拼接传...
exec (@execebaysql)
else
SELECT * FROM tb_EbayOrderUserInfo WITH (TABLOCKX)
if(@ebayuid>0)
if(@uid>0)
begin
if(@@TRANCOUNT>0)
SELECT * FROM tb_EbayOrderList WITH (TABLOCKX)
set @execebaysql=@ebaysql--存在ebayuid
else

end
@webwhere varchar(max),--web用户表where之后的sql语句
begin transaction mytrans
set @ebayuid =ISNULL(@ebayuid,0)
set xact_abort on
begin try
)
declare @uid int--根据语句查找用户ID
end
set @execebaysql= REPLACE(@execebaysql,'@ebayuid',''+convert(varchar,@ebayuid)+'')--必须替换 否则会报错误说必须声明标量变量
exec sp_common_WebSiteorder_AddInfo @websql, @webusersql, @webwhere ,@webstockflag
set @sql='select @a=ID from tb_TransactionCustomer where '+ convert(varchar(8000),@paypaluserwhere)
end catch
declare @execsql varchar(max)
end try
@webusersql varchar(max),--web用户表的sql语句
@paypalusersql varchar(max),--paypal用户表的sql语句
begin
declare @execebaysql nvarchar(max)--用sp_executesql 字段类型必须是nvarchar
declare @ebayuid int--根据语句查找用户ID
begin
exec(@execsql)
@ebayusersql varchar(max),--ebay的用户表sql语句
rollback transaction mytrans
exec sp_executesql @sql,N'@a int output',@uid output
set @execebaysql= REPLACE(@execebaysql,'@00',dbo.GetOrderNum(@ebaystockflag))--调用函数替换订单编号
SELECT * FROM tb_EbayOrder WITH (TABLOCKX)
else begin


@paypaluserwhere varchar(max),--paypal用户表查询ID语句
set @execebaysql=@ebayusersql+@ebaysql --不存在ebayuid
begin

复制代码 代码如下:

declare @sql nvarchar(max)--用sp_executesql 字段类型必须是nvarchar
if(@@TRANCOUNT>0)
begin
begin catch
end
--exec sp_common_Ebay_AddInfo @ebaysql, @ebayusersql, @ebayuserwhere ,@ebaystockflag
end
set @uid =ISNULL(@uid,0)--如果不这样判断 获取的值可能为null用len()获取不到长度
(
ALTER proc [dbo].[sp_common_paypal_AddInfo]
begin
set @execsql= REPLACE(@execsql,'@uid',''+convert(varchar,@uid)+'')
if(LEN(@websql)>0)--执行web语句
rollback transaction mytrans
end
as
begin
@paypalsql varchar(max),--不包含用户表的paypalsql语句
set @sql='select @b=ID from tb_EbayOrderUserInfo where '+ convert(varchar(8000),@ebayuserwhere)
exec sp_executesql @sql,N'@b int output',@ebayuid output
set @execsql=@paypalusersql+@paypalsql --不存在用户信息
end
--存在paypal用户id
if(LEN(@ebaysql)>0)--执行ebay语句
end
commit transaction mytrans
@webstockflag varchar(10)--web订单号生成规则
@ebayuserwhere varchar(max),--ebay用户表查询ID语句
@websql varchar(max),--web除去用户表的sql语句
@ebaystockflag varchar(10),--ebay订单号生成规则
set @execsql=@paypalsql-- 存在用户信息
end
@ebaysql varchar(max),--不包含用户表的ebaysql语句

相关热词:

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供用于网络技术学习参考,学习中请遵循相关法律法规!

本文地址: https://v30.fanwenzhu.com/sql/mssql/1492.shtml

Copyright © www.juheyunku.com      关于 | 合作 | 声明 | 联系 | 更新 | 地图 | Tags

动态SQL中返回数值的实现代码

2020-12-08 编辑:网络

exec (@execebaysql)
else
SELECT * FROM tb_EbayOrderUserInfo WITH (TABLOCKX)
if(@ebayuid>0)
if(@uid>0)
begin
if(@@TRANCOUNT>0)
SELECT * FROM tb_EbayOrderList WITH (TABLOCKX)
set @execebaysql=@ebaysql--存在ebayuid
else

end
@webwhere varchar(max),--web用户表where之后的sql语句
begin transaction mytrans
set @ebayuid =ISNULL(@ebayuid,0)
set xact_abort on
begin try
)
declare @uid int--根据语句查找用户ID
end
set @execebaysql= REPLACE(@execebaysql,'@ebayuid',''+convert(varchar,@ebayuid)+'')--必须替换 否则会报错误说必须声明标量变量
exec sp_common_WebSiteorder_AddInfo @websql, @webusersql, @webwhere ,@webstockflag
set @sql='select @a=ID from tb_TransactionCustomer where '+ convert(varchar(8000),@paypaluserwhere)
end catch
declare @execsql varchar(max)
end try
@webusersql varchar(max),--web用户表的sql语句
@paypalusersql varchar(max),--paypal用户表的sql语句
begin
declare @execebaysql nvarchar(max)--用sp_executesql 字段类型必须是nvarchar
declare @ebayuid int--根据语句查找用户ID
begin
exec(@execsql)
@ebayusersql varchar(max),--ebay的用户表sql语句
rollback transaction mytrans
exec sp_executesql @sql,N'@a int output',@uid output
set @execebaysql= REPLACE(@execebaysql,'@00',dbo.GetOrderNum(@ebaystockflag))--调用函数替换订单编号
SELECT * FROM tb_EbayOrder WITH (TABLOCKX)
else begin


@paypaluserwhere varchar(max),--paypal用户表查询ID语句
set @execebaysql=@ebayusersql+@ebaysql --不存在ebayuid
begin

复制代码 代码如下:

declare @sql nvarchar(max)--用sp_executesql 字段类型必须是nvarchar
if(@@TRANCOUNT>0)
begin
begin catch
end
--exec sp_common_Ebay_AddInfo @ebaysql, @ebayusersql, @ebayuserwhere ,@ebaystockflag
end
set @uid =ISNULL(@uid,0)--如果不这样判断 获取的值可能为null用len()获取不到长度
(
ALTER proc [dbo].[sp_common_paypal_AddInfo]
begin
set @execsql= REPLACE(@execsql,'@uid',''+convert(varchar,@uid)+'')
if(LEN(@websql)>0)--执行web语句
rollback transaction mytrans
end
as
begin
@paypalsql varchar(max),--不包含用户表的paypalsql语句
set @sql='select @b=ID from tb_EbayOrderUserInfo where '+ convert(varchar(8000),@ebayuserwhere)
exec sp_executesql @sql,N'@b int output',@ebayuid output
set @execsql=@paypalusersql+@paypalsql --不存在用户信息
end
--存在paypal用户id
if(LEN(@ebaysql)>0)--执行ebay语句
end
commit transaction mytrans
@webstockflag varchar(10)--web订单号生成规则
@ebayuserwhere varchar(max),--ebay用户表查询ID语句
@websql varchar(max),--web除去用户表的sql语句
@ebaystockflag varchar(10),--ebay订单号生成规则
set @execsql=@paypalsql-- 存在用户信息
end
@ebaysql varchar(max),--不包含用户表的ebaysql语句

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供学习参考!
本文地址为 https://v30.fanwenzhu.com/sql/mssql/1492.shtml

相关文章

风云图片

推荐阅读

返回mssql频道首页